﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NavigateXml.aspx.cs" %><?xml version="1.0"?>
<%@ Import Namespace="System.Linq" %>
<%@ Import Namespace="BusLib" %>
<%
    BusLib.Navigator navi = new Navigator();
    navi.RecalculatePlan();
%>
<navigate>
    <%
        foreach (Navigator.PlanStep ps in navi.plan)
        {
        %>
    <step mode="<%= ps.doing.ToString() %>">
        <start_pt time="<%= ps.startTime %>">            
            <lat><%= ps.startPt.latitude%></lat>
            <lon><%= ps.startPt.longitude%></lon>
        </start_pt>
        <end_pt time="<%= ps.endTime %>">
            <lat><%= ps.endPt.latitude%></lat>
            <lon><%= ps.endPt.longitude%></lon>
        </end_pt>
<%
        if (ps.doing == Navigator.State.Riding
            || ps.doing == Navigator.State.Waiting)
        {
            %><trip id="<%=ps.trip.trip_id %>">
                <route_num><%= ps.trip.Route.route_short_name%></route_num>
                <headsign><%= ps.trip.trip_headsign %></headsign>
            </trip><%
        }
%>
        
        <shape><%
        foreach (LatLong p in ps.GetShapePoints())
        {
             %>        
            <point>
                <lat><%= p.latitude%></lat>
                <lon><%= p.longitude%></lon>
            </point>
            <%
        }
             %>
        </shape>
    </step>
        
    <% }%>
</navigate>